﻿//-----------------------------------------------------------------------
// <copyright file="Users.cs" company="Craig Longford (deltawolf7@gmail.com)">
//     Copyright (c) Craig Longford. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Delta.Mercury.Business.User
{
    using System;
    using System.Collections.Generic;
    using Delta.Data.DataExpress;

    /// <summary>
    /// Collection of users
    /// </summary>
    [Serializable]
    public class Users : List<IUser>
    {
        #region Constructors
        /// <summary>
        /// Initializes a new instance of the Users class.
        /// </summary>
        public Users()
        {
        }
        #endregion

        #region Load Methods
        /// <summary>
        /// Load all users
        /// </summary>
        /// <param name="showDeleted">Show deleted users</param>
        /// <returns>Collection of users</returns>
        public static Users Load(bool showDeleted)
        {
            Parameters parameters = new Parameters();
            parameters.Add(new Parameter("Deleted", showDeleted));
            return DataAccess.GetCollection<Users, User>("LoadUsers", System.Data.CommandType.StoredProcedure, parameters);
        }

        /// <summary>
        /// Load all users
        /// </summary>
        /// <param name="showAdministrators">Show adminstrators</param>
        /// <param name="showDeleted">Show deleted users</param>
        /// <returns>Collection of users</returns>
        public static Users Load(bool showAdministrators, bool showDeleted)
        {
            Parameters parameters = new Parameters();
            parameters.Add(new Parameter("Deleted", showDeleted));
            parameters.Add(new Parameter("Admin", showAdministrators));
            return DataAccess.GetCollection<Users, User>("LoadUsers", System.Data.CommandType.StoredProcedure, parameters);
        }
        #endregion

        #region Search Methods
        /// <summary>
        /// Search users
        /// </summary>
        /// <param name="query">Query to search by</param>
        /// <param name="showDeleted">Show deleted</param>
        /// <returns>Collection of users</returns>
        public static Users Search(string query, bool showDeleted)
        {
            Parameters parameters = new Parameters();
            parameters.Add(new Parameter("Query", query));
            parameters.Add(new Parameter("Deleted", showDeleted));
            return DataAccess.GetCollection<Users, User>("SearchUsers", System.Data.CommandType.StoredProcedure, parameters);
        }
        #endregion
    }
}
